package com.example.javaui.slice;

import com.example.javaui.*;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_slice_main);

        Button btnComponent = (Button) findComponentById(ResourceTable.Id_btn_component);
        btnComponent.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                // 启动ComponentAbility
                startAbility(Utils.generatePageNavigationIntent(ComponentAbility.class.getName()));
            }
        });


        Button btnLayout = (Button) findComponentById(ResourceTable.Id_btn_layout);
        btnLayout.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                // 启动LayoutAbility
                startAbility(Utils.generatePageNavigationIntent(LayoutAbility.class.getName()));
            }
        });

        Button btnDialog = (Button) findComponentById(ResourceTable.Id_btn_dialog);
        btnDialog.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                // 启动DialogAbility
                startAbility(Utils.generatePageNavigationIntent(DialogAbility.class.getName()));
            }
        });

        Button btnListContainer = (Button) findComponentById(ResourceTable.Id_btn_list_container);
        btnListContainer.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                // 启动ListContainerAbility
                startAbility(Utils.generatePageNavigationIntent(ListContainerAbility.class.getName()));
            }
        });

        Button btnTab = (Button) findComponentById(ResourceTable.Id_btn_tab);
        btnTab.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                // 启动TabAbility
                startAbility(Utils.generatePageNavigationIntent(TabAbility.class.getName()));
            }
        });

        Button btnNeumorphism = (Button) findComponentById(ResourceTable.Id_btn_neumorphism);
        btnNeumorphism.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                // 启动NeumorphismAbility
                startAbility(Utils.generatePageNavigationIntent(NeumorphismAbility.class.getName()));
            }
        });

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
